<?php
namespace My\Controller;

use Utuo\BackgroundController;

class ProductGoodsConfigController extends BackgroundController {

	public function _initialize() {
		$this->setControllerTitle("栏目配置");
		$this->setActionTitle(array(
				'index' => '栏目配置',
		));
		$this->setActionNav("index");
	}

	public function indexAction() {
		$id = I('id', 0, 'intval');
		$productGoodsConfig = M("ProductGoodsConfig")->where(array('cid'=>$this->aid, 'id'=>$id))->find();
		if ( !$productGoodsConfig ) {
			$productGoods = M("ProductGoods")->where(array('cid'=>$this->aid, 'id'=>$id))->find();
			$productGoodsConfig = array(
					'id' => $productGoods['id'],
					'cid' => $this->aid,
					'page_title' => $productGoods['name'],
					'page_keywords' => $productGoods['name'],
					'page_content' => "",
			);
			false !== M("ProductGoodsConfig")->add($productGoodsConfig) or $this->error("初始数据失败!");
		}
		$this->assign("productGoodsConfig", $productGoodsConfig);
		$this->display();
	}

	public function saveAction() {
		$this->submitPost("ProductGoodsConfig");
	}

}